package leecode

func validateStackSequences(pushed []int, popped []int) bool {
	//新建一个辅助栈
	assist := make([]int, 0)
	index := 0
	for i := 0; i < len(pushed); i++ {
		//入栈
		assist = append(assist, pushed[i])
		for len(assist) > 0 && assist[len(assist)-1] == popped[index] {
			assist = assist[:len(assist)-1]
			index++
		}
	}
	return len(assist) == 0
}
